<template>
	<view style="padding-bottom: 50px;">
		<my_address></my_address>
		<view>
			<view
				style="display: flex;justify-content: start;align-items: center;border-bottom: 1px solid rgba(0,0,0,0.2);margin-bottom: 20px;padding: 10px 0pt;">
				<uni-icons type="shop" size="30"></uni-icons>
				<text style="padding: 0 15px;">购物车</text>
			</view>
			<view v-for="(item,index) in cart" :key="index" style="margin-bottom: 40rpx;padding: 0 10px;">
				<uni-swipe-action>
					<uni-swipe-action-item :right-options="options" @click="onClick(item)">
						<good-list :goods="item" :showRadio="true" @Onradio="changeRadio" :showNumberBox="true"
							@ChangeNum="ChangeNum" @Myclick="to_detail(item)"></good-list>
					</uni-swipe-action-item>
				</uni-swipe-action>
			</view>
		</view>
		<settlement></settlement>
	</view>
</template>

<script>
	import {
		mapGetters,
		mapState,
		mapMutations
	} from 'vuex'
	import badgMix from '../../mixins/tabbar-badge.js'
	export default {
		mixins: [badgMix],
		data() {
			return {
				options: [{
					text: '删除',
					style: {
						backgroundColor: '#c00000'
					}
				}]
			}
		},
		methods: {
			...mapMutations('m_cart', ['changeGood_state', 'changeGoods_count', 'delete_goods']),
			changeRadio(e) {
				this.changeGood_state(e)
			},
			ChangeNum(saveNum) {
				this.changeGoods_count(saveNum)
			},
			onClick(goods) {
				// console.log(e);
				// if(e.content.text==="删除"){
				// 	console.log("haha");
				// }
				// console.log(goods);
				this.delete_goods(goods)
			},
			to_detail(goods) {
				console.log(goods);
				console.log("123");
				uni.navigateTo({
					url: '../../subpkg/goods_detail/goods_detail?goods_id=' + goods.goods_id
				})
			}
		},
		computed: {
			...mapGetters('m_cart', ['total']),
			...mapState('m_cart', ['cart']),

		}
	}
</script>

<style lang="scss">

</style>
